package com.zhu.shiroweb;

import java.util.Set;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.zhu.shiroweb.dao.UserDao;
import com.zhu.shiroweb.entity.User;
import com.zhu.shiroweb.service.UserService;
import com.zhu.shiroweb.service.Impl.UserServiceImpl;

public class test {

	public static void main(String[] args) {
		ApplicationContext pp = new ClassPathXmlApplicationContext("applicationContext.xml");
		UserDao userDao = pp.getBean(UserDao.class);
		UserService userService = (UserService) pp.getBean(UserServiceImpl.class);
		Set<String> permissions2 = userService.getPermissions("tom");
		String userName = "tom";
		User u = userDao.getByUserName(userName);
		Set<String> roles = userDao.getRoles(userName);
		Set<String> permissions = userDao.getPermissions(userName);
		System.out.println(u.getPassword());
		for(String role : roles) {
			System.out.println(role);
		}
		for(String permission : permissions) {
			System.out.println(permission);
		}
		
		for(String permission : permissions2) {
			System.out.println(permission);
		}

	}

}
